package nz.co.senanque.perspectivemanager;

import java.io.Serializable;

import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.core.io.Resource;

/**
 * Encapsulates a sub-application that can be plugged into the perspectives manager.
 * The UI part of the application is held in the ComponentContainer.
 * The MenuBar will be merged with the menu in the main application (and de-merged
 * when we switch away from this application)
 * 
 * @author Roger Parkinson
 *
 */
public class SubApplicationimpl implements SubApplication, Serializable  {
	
	private static final long serialVersionUID = -1367277688477759273L;
	private String m_caption;
	private String m_description;
	private Resource m_icon;
	private MessageSource m_messageSource;
	private MessageSourceAccessor m_messageSourceAccessor;
	private AppFactory m_appFactory;
	private String m_version;

    public void setMessageSource(MessageSource messageSource)
    {
    	m_messageSource = messageSource;
        m_messageSourceAccessor = new MessageSourceAccessor(messageSource);
    }
	/* (non-Javadoc)
	 * @see nz.co.maduraperspectivemanager.SubApplication#getCaption()
	 */
	public String getCaption() {
		return (m_caption==null)?null:m_messageSourceAccessor.getMessage(m_caption,null,m_caption);
	}

	/* (non-Javadoc)
	 * @see nz.co.maduraperspectivemanager.SubApplication#getTooltip()
	 */
	public String getDescription() {
		return (m_description==null)?null:m_messageSourceAccessor.getMessage(m_description,null,m_description);
	}

	public void setCaption(String caption) {
		m_caption = caption;
	}

	public void setDescription(String description) {
		m_description = description;
	}

	public Resource getIcon() {
		return m_icon;
	}
	public void setIcon(Resource icon) {
		m_icon = icon;
	}
	public String getVersion() {
		return m_version;
	}
	public void setVersion(String version) {
		m_version = version;
	}
	public MessageSource getMessageSource() {
		return m_messageSource;
	}
	public AppFactory getAppFactory() {
		return m_appFactory;
	}
	public void setAppFactory(AppFactory appFactory) {
		m_appFactory = appFactory;
	}

}
